package com.study.service.Impl;

import com.study.dao.Impl.UserDaoImpl;
import com.study.dao.UserDao;
import com.study.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

//        <bean id="userService1" class="com.study.service.Impl.UserServiceImpl">
//<property name="userDao" ref="userDao1"></property>
//</bean>
//@Component("userService1")
@Service("userService1")
@Scope("prototype")
public class UserServiceImpl implements UserService {
	@Value("${jdbc.driver}")
	private String driver;
	private UserDao userDao = new UserDaoImpl();

//	@Autowired
//	@Qualifier("userDao1")
	@Resource(name="userDao1")
	public void setUserDao(UserDao userDao) {
//		System.out.println("public void setUserDao(UserDao userDao)");
		this.userDao = userDao;
	}

	public void save() {
//		System.out.println(new UserServiceImpl());
		System.out.println(driver);
		System.out.println("this is UserServiceImpl ===> save()");
	}

	@PostConstruct
	public void init(){
		System.out.println("init()");
	}

	@PreDestroy
	public void destory(){
		System.out.println("destory()");
	}
}
